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

Cloud we add ‘this.itemCount = 0;’ in internalInitialize(246 line) in org.eclipse.serializer.persistence.binary.types.BinaryStorer #111

Closed
useryq8 opened this issue Mar 7, 2024 · 1 comment · Fixed by #112
Labels
bug Something isn't working

Comments

@useryq8
Copy link

useryq8 commented Mar 7, 2024

Environment Details

  • Eclipse Serializer Version: 1.2.0
  • JDK version:21.0.1
  • OS:Ubuntu 17
  • Used frameworks: SpringBoot 2.7.8

Describe the bug

Maybe it is not bug, only some things which affect the performance. After adding the ‘this.itemCount = 0;’, the performance is higher than default. it seems that the default clean forge to set the itemCount to zero.

image

` protected void internalInitialize(final int hashLength)
{
synchronized(this.head)
{
this.itemCount = 0;
this.hashSlots = new Item[hashLength];
this.hashRange = hashLength - 1;

			// initializing/clearing item chain
			(this.tail = this.head).next = null;
			
			this.synchCreateStoringChunksBuffers();
		}
	}
	`

Could we do like this and it is safe? @hg-ms , thank you in advance!

To Reproduce

Use LazyArrayList as DataRoot, write and delete very frequently. and log the write/delete time cost, you will find the write/delete cost is relative high, maybe 10ms-200ms. I only used 2k threads to write/delete, I wrapper the LazyArrayList by a ReadWriteLock for concurrently operation.

Expected behavior

the write/delete cost will be small.

Screenshots

Additional context

@hg-ms
Copy link
Contributor

hg-ms commented Mar 8, 2024

Thanks for the issue, this should be fixed.
The itemCount should be set to zero when (re)initializing a storer instance. If not it will add up if a storer instance is used several times and can cause unnecessary resizing of the internal Item array.

@hg-ms hg-ms added the bug Something isn't working label Mar 8, 2024
@hg-ms hg-ms linked a pull request Mar 8, 2024 that will close this issue
@hg-ms hg-ms closed this as completed in #112 Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants