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

Repo indexer - Max file size #3457

Closed
ghost opened this issue Feb 5, 2018 · 22 comments
Closed

Repo indexer - Max file size #3457

ghost opened this issue Feb 5, 2018 · 22 comments
Labels
status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR type/bug type/upstream This is an issue in one of Gitea's dependencies and should be reported there

Comments

@ghost
Copy link

ghost commented Feb 5, 2018

gitea v1.4.0-rc1

I am trying to change the repo indexer max file size. I setted it to 5242880, but the repo file size is fixed to:

immagine

Seems that the setting doesn't be load correctly:
immagine

I also tried to change the setting, and erased the repo folder, but anyway the size seems to be fixed.

Regards

@lafriks lafriks added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Feb 5, 2018
@lafriks
Copy link
Member

lafriks commented Feb 5, 2018

MAX_FILE_SIZE is not for index size but for up to how big files to index

@ghost
Copy link
Author

ghost commented Feb 5, 2018

Thank you for your fast answer @lafriks . Then, what about the fixed "store" file size? I am trying to indexing a big project, and some of the files was indexed, but seems to be that not everyone, and I supposed that it depends maybe from the "file size"

@lafriks
Copy link
Member

lafriks commented Feb 5, 2018

how big is file that was not indexed?

@ghost
Copy link
Author

ghost commented Feb 5, 2018

Only 9KB, and is a Java file

@lafriks
Copy link
Member

lafriks commented Feb 5, 2018

Do you see any errors in log file? and why do you think it was not indexed?

@ghost
Copy link
Author

ghost commented Feb 5, 2018

No errors in log file. I am sure that the file was not indexed because I am trying to look also for other strings inside this file, but no results appear.

@ghost
Copy link
Author

ghost commented Feb 5, 2018

I just replicated the problem. If I create a new repository with just this file and just this repo, then the file is indexed correctly. I think that the problem is the max "store" file size

@lafriks
Copy link
Member

lafriks commented Feb 5, 2018

I don't think there is maximal size for store file

@ghost
Copy link
Author

ghost commented Feb 5, 2018

You can try to replicate the problem by cloning the repo: https://github.com/Xilinx/u-boot-xlnx
and search for string: "dm_test_adc_bind" (that is present in file "test/dm/adc.c"). Even in this case, the store file goes to a size of 1.048.576 KB and stop working (stop to grow up and to index files)

@lafriks
Copy link
Member

lafriks commented Feb 5, 2018

@ethantkoenig can you check this?

@ghost
Copy link
Author

ghost commented Feb 5, 2018

@ethantkoenig @lafriks Thank you. I also want to add an additional information: with the same repository occured also an access violation during repo indexing: Exception

@ethantkoenig
Copy link
Member

In my experience, bleve does not do well once index files approach/exceed 1 GB (although it may be different for other machines and OS's). I do recall seeing similar behavior at some point (where an index file remained the exact same size as more content was added to it), but wasn't able to figure out what was going on.

I have found that using sharded indices (not natively supported by bleve) allows bleve to scale more gracefully. Perhaps this is something to consider using in gitea.

@ghost
Copy link
Author

ghost commented Feb 6, 2018

Thank you for your answer @ethantkoenig . Are there any workaround to avoid this behavior?

@ghost
Copy link
Author

ghost commented Feb 6, 2018

I also want to add some external links to boltdb:
boltdb/bolt#266
boltdb/bolt#308
https://github.com/boltdb/bolt/blob/master/db.go (check comments at row 17, and starting from line 305)
Are those useful?

@ghost
Copy link
Author

ghost commented Feb 8, 2018

@ethantkoenig an additional information: your lasts commit on master, changed the store max size to 524.288 KB, instead of, for "v1.4.0-rc1" the size is fixed to 1.048.576 KB

@ghost
Copy link
Author

ghost commented Feb 10, 2018

@ethantkoenig @lafriks After hours of reverse engineering I think that I found the problem about max store sizing on gitea v1.4.0-rc1. On monday I will test mine tricky-hack on production gitea, and I will let you know about it here

@lafriks
Copy link
Member

lafriks commented Feb 10, 2018

@giudon that's great to hear

@ghost
Copy link
Author

ghost commented Feb 12, 2018

@ethantkoenig @lafriks Now I can confirm my analisys: there is a problem in boltdb. In particular it happens in such particular cases, when is needed to remap the store file after 1GB. The problem is still present in the master version, because I seen that on gitea we are using this db.go version https://github.com/boltdb/bolt/blob/ccd680d8c1a0179ac3d68f692b01e1a1589cbfc7/db.go (this commit was done by @lunny , and after this there is only one commit more, that doesn't change the remap logic on db.go).
The following are the technical details (before start, I want to say that my OS pageSize, on a Windows 64 bit machine is equal to 4.096 bytes):
When boltdb needs to allocate new "junk" to store file, this method is called:
immagine
as you can see, when is needed to increase the store file is called the method "mmap" with a minimum size reallocation parameter. Inside "mmap" is called the method "mmapSize", that calculate the new store file size based on the minimum one passed as parameter:
immagine
as you can see from my red comments, there are 2 different calculation methods inside "mmapSize". The first one calculate the new store size following this rule, based on the minimum size parameter:
2^15 = 32.768 bytes
2^16 = 65.536 bytes
2^17 = 131.072 bytes
2^18 = 262.144 bytes
2^19 = 524.288 bytes
2^20 = 1.048.576 bytes
2^21 = 2.097.152 bytes
2^22 = 4.194.304 bytes
2^23 = 8.388.608 bytes
2^24 = 16.777.216 bytes
2^25 = 33.554.432 bytes
2^26 = 67.108.864 bytes
2^27 = 134.217.728 bytes
2^28 = 268.435.456 bytes
2^29 = 536.870.912 bytes
2^30 = 1.073.741.824 bytes
and this method works well.
The problems starts when the second calculation method take control over remap size, because the minimum size that is passed as parameter when 1GB is reached was "1.073.741.824", and not as I was expecting a value greater than "1.073.741.824".
So, when 1GB is reached, simply the mmapSize return the same minimum size passed as parameter (1.073.741.824), because following codes:
immagine
are not reached.

My little tricky-hack to let it works, is to comment the following red lines inside "mmapSize" method:
immagine
and so, when 1GB is reached, the new allocation size will be increased everytime by os.Getpagesize().
Now repo indexing work fine:
immagine

What do you think about it guys?

@lafriks lafriks added type/bug status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR and removed type/question Issue needs no code to be fixed, only a description on how to fix it yourself. labels Feb 12, 2018
@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

@giudon great bug hunting :) can you report this upstream to boltdb?

@ghost
Copy link
Author

ghost commented Feb 12, 2018

@lafriks did it

@guillep2k
Copy link
Member

Bolt have become archived/unmaintained. Proposed alternative seems to be https://github.com/etcd-io/bbolt. Perhaps it's worth taking a look at it?

@lunny lunny added the type/upstream This is an issue in one of Gitea's dependencies and should be reported there label Oct 20, 2022
@lunny
Copy link
Member

lunny commented Mar 27, 2024

It's outdated and now the latest version depends on go.etcd.io/bbolt indirectly.

@lunny lunny closed this as completed Mar 27, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR type/bug type/upstream This is an issue in one of Gitea's dependencies and should be reported there
Projects
None yet
Development

No branches or pull requests

4 participants