Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: eliminate the possibility of allocating too much direct memory #1657

Merged
merged 2 commits into from
Oct 10, 2019

Conversation

ggndnn
Copy link
Contributor

@ggndnn ggndnn commented Sep 16, 2019

Ⅰ. Describe what this PR did

In FileTransactionStoreManager, sometimes, data buffer size was not under control. For example when data size to write was bigger than writerBuffer:

...
ByteBuffer byteBuffer = null;

if (bs.length + 4 > MAX_WRITE_BUFFER_SIZE) {
    //allocateNew
    byteBuffer = ByteBuffer.allocateDirect(bs.length + 4);
} else {
...

Or in function findTimeoutAndSave:

...
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(totalSize);
for (byte[] bytes : listBytes) {
    byteBuffer.putInt(bytes.length);
    byteBuffer.put(bytes);
}
...

Those buffers' size was out of control, unlimited, that may be a hidden danger.

This PR makes fully use of the writerBuffer, eliminate the possibility of allocating too much memory.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Did.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Sep 16, 2019

Codecov Report

Merging #1657 into develop will increase coverage by 0.17%.
The diff coverage is 50%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #1657      +/-   ##
=============================================
+ Coverage      48.17%   48.35%   +0.17%     
- Complexity      1846     1858      +12     
=============================================
  Files            365      365              
  Lines          13308    13325      +17     
  Branches        1645     1652       +7     
=============================================
+ Hits            6411     6443      +32     
+ Misses          6233     6213      -20     
- Partials         664      669       +5
Impacted Files Coverage Δ Complexity Δ
...server/store/file/FileTransactionStoreManager.java 52.63% <50%> (+6.63%) 27 <4> (+8) ⬆️
...in/java/io/seata/server/session/GlobalSession.java 85.02% <0%> (+0.48%) 68% <0%> (+1%) ⬆️
...in/java/io/seata/server/session/BranchSession.java 80.45% <0%> (+2.25%) 44% <0%> (+3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1441069...faf3538. Read the comment docs.

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good job.

Copy link
Member

@jsbxyyx jsbxyyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jsbxyyx jsbxyyx merged commit eb7f2f6 into apache:develop Oct 10, 2019
dangquocbang pushed a commit to dangquocbang/seata that referenced this pull request Oct 14, 2019
* 'develop' of https://github.com/seata/seata:
  test: enhance test coverage of seata common (apache#1755)
  security: upgrade jackson to avoid security vulnerabilities (apache#1756)
  bugfix:rm channel register null resource (apache#1401)
  bugfix:fix memory lock is not released due to hash conflict (apache#1751)
  optimize:use raw types instead of boxing types (apache#1747)
  change get charset (apache#1707)
  fix undo support oracle table meta cache (apache#1749)
  bugfix: fix use 'in' and 'between' in where condition for Oracle and Mysql (apache#1699)
  optimize:add some server's jvm parameters (apache#1738)
  Saga implementation base on state machine (apache#1608)
  optimize:inner class may be static (apache#1706)
  feature: retry when tm commit or rollback failed (apache#1739)
  optimize: abstract common undolog manager method (apache#1712)
  bugfix: when tm commit or rollback failed,xid need to be clean (apache#1735)
  optimize: eliminate the possibility of allocating too much direct memory (apache#1657)
  Based on Java 5 optimization (apache#1705)
  bugfix: oracle batch insert error (apache#1729)

# Conflicts:
#	pom.xml
@wangliang181230 wangliang181230 added this to the 0.9.0 milestone Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants